/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import React from 'react';
import { Descriptions, Typography } from 'antd';
import type { KbDescriptionsColumns } from '@/components/KbDescriptions';
import type { ProColumns } from '@ant-design/pro-table';
import type { TableColumns } from './type';

const { Text } = Typography;
export const descriptionsMap: KbDescriptionsColumns[] = [
  {
    label: '执行的sql',
    dataIndex: 'sql',
  },
  {
    dataIndex: 'result',
    render: (_, record) => {
      const { result } = record;
      const text = result === '0' ? '失败' : result === '1' ? '成功' : '';
      const type = result === '1' ? 'success' : 'danger';
      return (
        <Descriptions.Item label='执行结果'>
          <Text type={type}>{text}</Text>
        </Descriptions.Item>
      );
    },
  },
  {
    label: '说明',
    dataIndex: 'message',
  },
  {
    label: '可能影响行数',
    dataIndex: 'effect_rows',
  },
  {
    label: '实际影响行数',
    dataIndex: 'real_effect_rows',
  },
];

export const newSqlColumns: ProColumns<TableColumns>[] = [
  {
    title: 'ID',
    dataIndex: 'Id',
    align: 'center',
    search: false,
    width: 100,
    ellipsis: true,
  },
  {
    title: 'db',
    dataIndex: 'db',
    align: 'center',
    search: false,
    width: 100,
    ellipsis: true,
  },
  {
    title: 'time',
    dataIndex: 'Time',
    align: 'center',
    search: false,
    width: 100,
    ellipsis: true,
  },
  {
    title: 'State',
    dataIndex: 'State',
    align: 'center',
    search: false,
    width: 100,
    ellipsis: true,
  },
  {
    title: 'sql',
    dataIndex: 'Info',
    align: 'center',
    search: false,
    width: 100,
    ellipsis: true,
  },
  {
    title: 'User',
    dataIndex: 'User',
    align: 'center',
    search: false,
    width: 100,
    ellipsis: true,
  },
];

export const processList = [
  'show processlist',
  'show full processlist',
  'SHOW PROCESSLIST',
  'SHOW FULL PROCESSLIST',
];
